// An object that implements Iterable exposes read-only access to a group of items
// The Collection class extends Iterable with the ability to add and remove items. List, Set, and Queue are all collections.
void main() {
  var numbers = new Iterable.generate(5, (i) => i);
  for (var number in numbers) {
    print(number);
  }

  //same as for in loop
  for (var iter = numbers.iterator; iter.moveNext();) {
    var number = iter.current;
    print(number);
  }

  var v1 = numbers.length;
  print(v1); //5
  var v2 = numbers.any((int i) => i.isEven); //偶数
  print(v2); //true
  var v3 = numbers.contains(10);
  print(v3); //false
  var v4 = numbers.where((i) => i.isOdd).toSet();
  print(v4);
  // 1, 3
  var v5 = numbers.map((i) => i * 2).toList();
  print(v5);
  print(v5 is List); //true
  // 0, 2, 4, 6, 8
}
//EOP
